import com.sun.org.apache.xpath.internal.functions.FuncExtElementAvailable;

import java.util.Scanner;

class Cat implements Cloneable {
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test {
       public static int func(int[] array,int n)  {
           if (array == null) {
               throw new NullPointerException("该数组为kong");
           }else if (n >= array.length || n < 0) {
               throw new ArrayIndexOutOfBoundsException("数组越界");
           }
           System.out.println("运行成功");
           return array[n];
       }
public static int func() {
    try  {
        int a=10;
        return a;
    } catch (NullPointerException e) {
        System.out.println("捕获到了空指针这个异常！！！");
        return 1;
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("抓到了数组越界这个异常");
        return 2;
    } finally {
        System.out.println("try-catch-finally之后代码");
        return 9;
    }
}
     public static int func(int x) {
       if (x<0||x>100) {
           throw new FractionException("成绩错误");
       }
       else return x;
      }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
            System.out.println(func(scanner.nextInt()));
        } catch (FractionException e) {
            e.printStackTrace();
            System.out.println("成绩错误，请重新输入");
        }
        System.out.println("运行后续代码.....");
    }
    public static void main2(String[] args) {
            int n= func();
        System.out.println(n);


    }
    public static void main1(String[] args)  {
        int []array={2,4,6,8,10};
        try {
            System.out.println(func(array, 6));
        }catch (NullPointerException e) {
            System.out.println("捕获到了空指针这个异常！！！");
        }catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("抓到了数组越界这个异常");
            e.printStackTrace();
        }
        System.out.println("我是后续代码.....");
    }
}
class FractionException extends RuntimeException{
    public FractionException(String message) {
        super(message);
    }
}